package www.java.quickSortTest;

public class Test {
    private static   int  Partition(int[]  arr,int start,int end){
        int key=arr[start];
        while (start<end){
            while (arr[end]>=key&&end>start){
                end--;
            }
            arr[start]=arr[end];
            while (arr[start]<=key&&end>start){
                start++;
            }
            arr[end]=arr[start];
        }
        arr[start]=key;
        return start;
    }
    public  static void  quickSort(int []  arr,int start,int   end){
        if (start<end)
        {

            int  index=Partition( arr, start, end);
            quickSort( arr,start,index-1);
            quickSort( arr,index+1,end);
        }
    }

    public static void main(String[] args) {
        int []  arr={1,2,5,3,4,1,6,3,8};
        quickSort(arr,0,arr.length-1);
        for (int temp:arr){
            System.out.print(temp+",");
        }

    }
}
